<?php


namespace App\Helpers;


use App\Models\Car\CarStatistic;
use App\Models\Order;
use Illuminate\Support\Carbon;
use Modules\Car\Entities\CarOrder;
use Modules\Car\Entities\ForbidLeaseDate;
use Modules\Car\Entities\RecognizeDrivingLicense;
use Modules\Manager\Entities\Manager;
use Yansongda\Pay\Pay;
use function AlibabaCloud\Client\json;

trait CommTrait
{
    protected function getManager($department_id){
        return Manager::query()
            ->whereIn('id',[$department_id,0])
            ->where('wechat_openid','<>','')
            ->pluck('wechat_openid');
    }
    // 事故完成 统计
    protected function serviceFinishedStatstatic($data){
        $data = CarStatistic::query()->where('car_id',$data->car_id)->first();
        if(!$data){
             info('事故维修统计未找到事故维修订单');
             return false;
        }
        $data->total_amount = $data->total_amount+$data->repair_price;
        $data->save();
    }
    // 支出统计
    protected function expendStatistatic($car_id,$amount){
        $data = CarStatistic::query()->where('car_id',$car_id)->first();
        if(!$data){
            info('修统计未找到维修订单');
            return false;
        }
        $data->total_amount = $data->total_amount-$amount;
        $data->save();
    }
}
